package com.unism.unisdk.common.enumObj;
/**
 * sdk服务支持的http请求方式(暂时仅支持get/post)
 * @author liuc
 */
public enum HttpMethod {
    GET("GET",true),
    POST("POST",true),
    DELETE("DELETE",false),
    PUT("PUT",false);
	private String name;//请求的名称
	private Boolean support;//当前服务是否支持
	/**
	 * 判断sdk服务是否支持当前的http请求方法
	 * 默认为不支持
	 * @param method
	 * @return
	 */
	public Boolean isSupport(HttpMethod method){
		if(method != null){
			return method.getSupport();
		}
		return false;
	}
	public Boolean isSupport(String methodName){
		HttpMethod method=getMethodByName(methodName);
		return isSupport(method);
	}
	/**
	 * 根据请求方法名字获取对应的枚举类型
	 * @param methodName
	 * @return
	 */
	public HttpMethod getMethodByName(String methodName){
		if(methodName != null && !methodName.trim().equals("")){
			for(HttpMethod method : HttpMethod.values()){
				if(method.getName().trim().toLowerCase().equals(methodName.trim().toLowerCase())){
					return method;
				}
			}
		}
		return null;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Boolean getSupport() {
		return support;
	}
	public void setSupport(Boolean support) {
		this.support = support;
	}
	private HttpMethod(String name, Boolean support) {
		this.name = name;
		this.support = support;
	}
}
